
from stream import models
from django.http import Http404, HttpResponse
from django.shortcuts import get_object_or_404

def delete(request, model):
    id = int(request.POST['id'])
    instance = get_object_or_404(model, id = id)
    if hasattr(instance, 'owner'):
        owner = instance.owner()
    elif hasattr(instance, 'user'):
        owner = instance.user
    if owner != request.user:
        raise Http404
    instance.delete()
    return HttpResponse()
